<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Create tax browse page
 * get attribute.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
db::getInstance()->orderBy('attribute_title', 'ASC');
$result = db::getInstance()->get('attribute');

if (db::getInstance()->count <= 0)
{
	message::setErrorRow(_('Databaseerror! - Contact Admin!'), true);
}
else
{
	$refPage->assign('page_title', _('Userdefined attributes'));
	$refPage->assign('summary', _('This table gives a overview of the userdefined attributes'));

	$refPage->assign('attribute_id', _('ID'));
	$refPage->assign('attribute_name', _('Name'));
	$refPage->assign('attribute_option', _('Edit options'));

	$refPage->assign('Form_Start',
		'<form class="niceform fieldset taxTable" action="' .
		'index2.php?page=' . $page . '&sub=' . $subpage .
		'" method="post"><fieldset>');
	$refPage->assign('Form_End', '</fieldset></form>');
	$data = NULL;
	
	foreach ($result as $buffer)
	{
		$attribute_titley = '<a href="index2.php?page=' . $page . '&sub=' . $subpage .
			'&id=' . $buffer['attribute_id'] . '&func=edit">' . $buffer['attribute_title'] . '</a>';
		$attribute_optiony = '<a href="index2.php?page=' . $page . '&sub=' . $subpage .
			'&id=' . $buffer['attribute_id'] . '&func=options">' . _('Edit options') . '</a>';
		
		$data[] = array('attribute_set' => '<input type="checkbox" name="marker[]" value="' .
		 $buffer['attribute_id'] . '" />',
		 'attribute_idx' => $buffer['attribute_id'],
		 'attribute_namex' => $attribute_titley,
		 'attribute_optionx' => $attribute_optiony);
	}
	$refPage->assign('data', $data);

	$refPage->assign('btn_Delete',
		'<input type="submit" name="submit" id="delete" value="' .
		_('Delete') . '" />');
	$refPage->assign('btn_New',
		'<input type="submit" name="submit" id="new" value="' .
		_('New') . '" />');
	$refPage->assign('tableHelp', help('attributes', $page, TRUE));
	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.tpl.php');
}
?>